Elu ================= 逐元素计算指数线性单元 (Exponential Linear Unit, ELU) 激活函数。 .. math:: \text{output}_i = \begin{cases} \text{input}_i & \text{if } \text{input}_i \ge 0 \\ \alpha \cdot (e^{\text{input}_i} - 1) & \text{if } \text{input}_i < 0 \end{cases} 其中 :math:`\alpha` (alpha) 是一个可调参数,控制负值的饱和度。 输入: - **input** - 输入张量的数据地址。 - **alpha** - ELU函数的alpha值。 - **length** - 输入张量的总元素数量。 - **core_mask** - 核掩码。 输出: - **output** - 输出张量的数据地址,其大小与`input`相同。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - FT78NE 支持fp32, int8 - MT7004 支持fp16, fp32 **共享存储版本:** .. c:function:: void fp_elu_s(float* input, float* output, float alpha, int length, int core_mask) .. c:function:: void hp_elu_s(half* input, half* output, half alpha, int length, int core_mask) .. c:function:: void i8_elu_s(int8_t* input, int8_t* output, int8_t alpha, int length, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 12 //FT78NE示例 #include #include int main(int argc, char* argv[]) { float *input = (float *)0xA0000000; // input 在DDR空间 float *output = (float *)0xB0000000; // output float alpha = 1.0f; int length = 4096; int core_mask = 0xff; fp_elu_s(input, output, alpha, length, core_mask); return 0; } **私有存储版本:** .. c:function:: void fp_elu_p(float* input, float* output, float alpha, int length) .. c:function:: void hp_elu_p(half* input, half* output, half alpha, int length) .. c:function:: void i8_elu_p(int8_t* input, int8_t* output, int8_t alpha, int length) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 11 //FT78NE示例 #include #include int main(int argc, char* argv[]) { float *input = (float *)0x10000000; // input 在L2空间 float *output = (float *)0x11000000; // output float alpha = 1.0f; int length = 1024; fp_elu_p(input, output, alpha, length); return 0; }